
<div class="bjui-row col-2">
        <label class="row-label">名称</label>
        <div class="row-input required">
            <input type="text" name="name" id="customer-name" data-rule="required">
        </div>
        <label class="row-label">联系人</label>
        <div class="row-input ">
            <input type="text" name="contact" id="customer-contact">
        </div>
        <label class="row-label">联系电话</label>
        <div class="row-input">
            <input type="text" name="tel" id="customer-tel">
        </div>
        <label class="row-label">位置</label>
        <div class="row-input">
            <input type="text" name="location" id="customer-location">
        </div>
        <input type="hidden" id="customer-createdate">
        <input type="hidden" id="customer-getid" value="${id}">
        <input type="hidden" id="customer-id">
    </div>

    <div class="bjui-pageFooter">
        <ul>
            <li>
                <button type="button" class="btn-close" data-icon="close">取消</button>
            </li>
            <li>
                <button onclick="return commit()" type="submit"  class="btn-default" data-icon="save">保存</button>
            </li>
        </ul>
    </div>

<script>
    $(function () {
        var id = $("#customer-getid").val();
        console.log(id);
        //前台
        if (id !== "") {
            $.ajax({
                type: "POST",
                url: "/sysmanage/customer/getmodule.do",
                data: {'id':id},
                cache: true,
                dataType:'JSON',
                success:function(data){
                    bindModule(data);
                }
            })
        }
//        $("#addCustomer").click(function () {
//            BJUI.navtab('refresh', 'ownerInfo')
//        })
    });

    function commit() {
        var id = $("#customer-id").val();
        var name = $("#customer-name").val();
        var contact = $("#customer-contact").val();
        var tel = $("#customer-tel").val();
        var location = $("#customer-location").val();

        var moduledata = new Object();
        moduledata.id = id;
        moduledata.name = name;
        moduledata.contact = contact;
        moduledata.tel = tel;
        moduledata.location = location;
//        console.log(moduledata);
//        console.log(JSON.stringify(moduledata));
        $.ajax({
            type: "POST",
            url: "/sysmanage/customer/edit.do?",
            data: JSON.stringify(moduledata),
            cache: true,
            dataType: 'json',
            contentType: "application/json;charset=UTF-8",
            success: function (data) {
                if (data.Message === "ok") {
                    BJUI.alertmsg('ok', data.content);
                }
                BJUI.navtab('refresh', 'customer');
            }
        })
    }

    function bindModule(data) {
        $("#customer-id").val(data.id);
        $("#customer-name").val(data.name);
        $("#customer-contact").val(data.contact);
        $("#customer-tel").val(data.tel);
        $("#customer-location").val(data.location);
    }

</script>


